/**
 * @author Eduardo Leonne Souza de Oliveira
 * @version 1.0
 * Date: 2011-12-29
 * Last change: 2011-12-29 
 * 
 */

package com.leonne.harpacristabrasileira.dao;

import java.util.ArrayList;

import android.content.Context;
import android.database.Cursor;

import com.leonne.harpacristabrasileira.lists.vo.AnthemVO;
import com.leonne.harpacristabrasileira.lists.vo.VerseVO;
import com.leonne.harpacristabrasileira.tools.Utils;

public class ConfigurationsDAO extends GenericDAO {

	/**
	 * DAO created specifically to guarantee that the database structure will be
	 * created and populated
	 * 
	 * @param context
	 *            Application base context
	 */
	public ConfigurationsDAO(Context context) {
		super(context, "configurations");
	}
	
	/**
	 * Get records in the verses table
	 * 
	 * @return ArrayList A list of VerseVO objects
	 */
	public String fetchByDescription(String description) {
		String sql = "SELECT val "
				+"FROM configurations "
				+"WHERE description = '" + description + "'";
		Cursor cursor = this.getDatabase().rawQuery(sql, null);
		if (cursor.moveToFirst()) {
			do {
				return cursor.getString(0);
			} while (cursor.moveToNext());
		}
		return "";
	}
	
	public void setFontSize(int fontSize){
		String sql = "UPDATE configurations SET val='"+ String.valueOf(fontSize) +"' WHERE description = 'FONTSIZE'";
		this.execSql(sql);
	}
	
	public void setFirstTimeOpen(int firstTime) {
		String sql = "UPDATE configurations SET val='"+ String.valueOf(firstTime) +"' WHERE description = 'FIRSTTIME'";
		this.execSql(sql);
	}

}
